/*
 * queue.h
 *
 *  Created on: 2013-10-22
 *      Author: dj
 */

#ifndef QUEUE_H_
#define QUEUE_H_

#include "config.h"

struct msg {
	struct msg *self;
	int id;
	int len;
	void *data;
	int extra_len;
	void *extra_data;
};

typedef struct msg *msg_t;

class Queue {
public:
	Queue();
	Queue(int);
	~Queue();
	msg_t pop();
	int push(msg_t);
	msg_t msg_create(int, int);
	void msg_destroy(msg_t);
	int get_max_num();
private:
	int max_num;
	int front;
	int rear;
	msg_t *list;

private:
	pthread_mutex_t lock;
	sem_t sem;
};

#endif /* QUEUE_H_ */
